package com.example.shardingSphere.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class BaseEntity<T extends Model> extends Model {

    /**
     * 默认
     */
    public static final int DEFAULT_STATUS = 0;

    /**
     * 启用状态
     */
    public static final int USEIN_STATUS = 1;

    public static final String REDIS_STRING_KEY = "stringList";

    public static final String REDIS_ENTITY_KEY = "entityList";

    @TableId(value = "pkId")
    private Long pkId;                              //主键id

    @TableField(value = "fkId", exist = false)
    private Long fkId;                              // 外键id

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "createTime")
    private String createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "updateTime", exist = false)
    private String updateTime;

    @TableLogic
    @TableField(exist = false)
    private Integer flag;

    @Override
    protected Serializable pkVal() {
        return super.pkVal();
    }
}
 
